<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Blog extends MY_Controller {
    
    protected $_parentId;

    public function __construct()
    {
        parent::__construct();
        
        $this->_parentId = $this->config->item('BLOG_ID');
        
        //Load model
        $this->load->model('blog_m');
        
        //Set layout homepage
        $this->set_layout('frontend/blog');
    }

    /**
     * Default function
     */
    public function index()
    {
        //Set params
        $parentId = 
        
        //Get data
        $arrArticles = $this->blog_m->get_top_object_by_parentId($this->_parentId, 5, 0, array('type' => 1));
        $arrVideos = $this->blog_m->get_top_object_by_parentId($this->_parentId, 4, 0, array('type' => 3));
        
        //Assign to view
        $this->assign('arrArticles', $arrArticles);
        $this->assign('arrVideos', $arrVideos);
    }
    
    /**
     * view function
     * @param type $id 
     */
    public function view($id)
    {
        //Set array data default
        $arrData = $arrTop = array();
        
        //Check id valid
        if($id)
        {
            $arrData = $this->blog_m->get_object_detail($id);
            $arrTop = $this->blog_m->get_top_object_by_parentId($this->_parentId, 5, 0, array('type' => 1), 'num_views');
        }
        
        //Assign to view
        $this->assign('arrData', $arrData);
        $this->assign('arrTop', $arrTop);
    }
    
    /**
     * view video function
     * @param type $id 
     */
    public function view_video($id)
    {
        //Set array data default
        $arrData = array();
        
        //Check id valid
        if($id)
        {
            $arrData = $this->blog_m->get_object_detail($id); 
        }
        
        //Assign to view
        $this->assign('arrData', $arrData);
    }

}